import { vipService } from './../../../node_modules/.prisma/client/index.d';
import { BaseService } from '@/base/base.service';
import { pageData } from '@/util/util';
import { Injectable } from '@nestjs/common';
import { CreateVipServiceDto } from './dto/create-vip-service.dto';
import { UpdateVipServiceDto } from './dto/update-vip-service.dto';

@Injectable()
export class VipServiceService {

constructor(private readonly baseService: BaseService) {}

  async create(createVipServiceDto: CreateVipServiceDto) {
    await this.baseService.vipService.create({
      data: {
        ...createVipServiceDto
      }
    })
    return '添加成功'
  }

  async findAll() {
    return await this.baseService.vipService.findMany()
  }

  async findPage(query: any) {
    return await pageData<vipService>('vipService', query)
  }


  async findOne(id: string) {
    return await this.baseService.vipService.findUnique({
      where: {
        id
      }
    });
  }

  async update(id: string, updateVipServiceDto: UpdateVipServiceDto) {
    await this.baseService.vipService.update({
      where: {
        id
      },
      data: updateVipServiceDto
    })
    return '修改成功'
  }

  async remove(id: string) {
    await this.baseService.vipService.delete({
      where: {
        id
      }
    })
    return '删除成功'
  }

  manyRemove(idList: string[]) {
    idList.forEach(async item => {
      await this.remove(item)
    })
    return '删除成功'
  }
}
